package com.zhibang.report.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sannuo.common.domain.bo.Cs;
import com.sannuo.common.domain.bo.Jcsj;
import com.sannuo.common.result.Result;
import com.sannuo.common.result.ResultCode;
import com.zhibang.report.service.DetectorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Detector")
public class DetectorController {
    @Autowired
    private DetectorService detectorService;

    @RequestMapping(value = "sj",method = RequestMethod.GET)
    public Result ss(String headStore,String subStore,String csTime,String endTime) throws JsonProcessingException {
        Jcsj jcsj = new Jcsj();
        System.out.println("总店"+headStore+"分店"+subStore+"初始时间"+endTime+"结束时间");
        jcsj.setHeadStore(headStore);
        jcsj.setSubStore(subStore);
        jcsj.setCsTime(csTime);
        jcsj.setEndTime(endTime);
        Integer integer = detectorService.jcSelect(jcsj);
        List<Integer> list = new ArrayList<>();
        list.add(integer);
        return Result.ok(ResultCode.SUCCESS,list);
    }
    @RequestMapping(value = "kfxt",method = RequestMethod.GET)
    public Result kfxt(){
        List<Integer> list = new ArrayList<>();
        Integer integer = detectorService.jcKfXt();
        Integer integer1 = detectorService.jckfxt1();
        Integer integer2 = detectorService.jckfxt2();
        list.add(integer);
        list.add(integer1);
        list.add(integer2);
        return Result.ok(ResultCode.SUCCESS,list);
    }

    @RequestMapping(value = "ghnb1",method = RequestMethod.GET)
    public Result ss3(){
        List<Cs> cs = detectorService.selectStore();
        System.out.println("谷瀚"+cs);
        return Result.ok(ResultCode.SUCCESS,cs);
    }
    @RequestMapping(value = "ghnb2",method = RequestMethod.GET)
    public Result ss4(){
        List<Cs> cs = detectorService.selectAddress();
        System.out.println("牛逼"+cs);
        return Result.ok(ResultCode.SUCCESS,cs);
    }
}
